﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

using Microsoft.Practices.Unity;

using ERPStore.Extensions;
using ERPStore.Web.Routing;

using EventBrokR;

namespace ERPStore.Demo
{
	public class PluginInit : ERPStore.Extensibility.PluginInit
	{
		public PluginInit()
		{
			Container = GlobalConfiguration.Configuration.DependencyResolver.GetContainer();
		}

		Microsoft.Practices.Unity.IUnityContainer Container { get; set; }

		public override void AddServices()
		{
			var eb = Container.Resolve<EventBrokR.IPublisher>();
			eb.Container.Register<EventConsumers.ApplicationStartedEventConsumer>();
		}

		public override void RegisterRoutes()
		{
			RouteTable.Routes.MapERPStoreRoute(
				"HtmlStatic"
				, "ngviews/{*viewName}"
				, new { controller = "Home", action = "HtmlStaticPage" }
			);

			RouteTable.Routes.MapRoute(
				"AngularJSUITemplateStatic"
				, "template/{*viewName}"
				, new { controller = "AngularUI", action = "Template" }
				, new [] { "ERPStore.Demo.Controllers" }
			);

			RouteTable.Routes.MapRoute(
				"BootstrapImg"
				, "img/{*fileName}"
				, new { controller = "Bootstrap", action = "Img" }
				, new[] { "ERPStore.Demo.Controllers" }
			);

		}
	}
}